#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

ll n;

int ask(ll x) {
	cout << "? "<< x << endl;
	int res; cin >> res; return res;
}

mt19937 rnd(time(NULL));

void solve() {
	cin >> n;
	ll l = 1, r = n - 1;
	vector < ll > pot;
	while(l <= r) {
		ll mid = l + r >> 1;
		pot.eb(mid); l = mid + 1;
	}
	reverse(pot.begin(), pot.end());
	ll pw = 1, st = 1;
	for(auto v : pot) st += pw * v, pw = -pw;
	l = 1, r = n - 1; ll ans = n; ask(st);
	while(l <= r) {
		ll mid = l + r >> 1;
		st = st + mid * pw; pot.pop_back(); pw = -pw;
		if(ask(st)) ans = mid, r = mid - 1;
		else l = mid + 1;
	} cout << "= " << ans << endl;
}

int main() {
#ifndef ONLINE_JUDGE
	//freopen("1.in", "r", stdin);
#endif
	int T; cin >> T; while(T--) solve();
	return 0;
}
